<template>
  <div class="login flexCenter2">
    <div class="loginForm">
      <a-form-model
        ref="ruleForm"
        :model="form"
        :rules="rules"
        :label-col="labelCol"
        :wrapper-col="wrapperCol"
        labelAlign="left"
      >
        <a-form-model-item ref="account" label="账号" prop="account">
          <a-input
            v-model="form.account"
            @blur="
          () => {
            $refs.account.onFieldBlur();
          }
        "
          />
        </a-form-model-item>

        <a-form-model-item ref="password" label="密码" prop="password">
          <a-input
            v-model="form.password"
            @blur="
          () => {
            $refs.password.onFieldBlur();
          }
        "
          />
        </a-form-model-item>
        <a-form-model-item style="width:100%" :labelCol="lab0"
      :wrapperCol="wrap24">
          <a-button type="primary" style="width:100%" @click="login">登录</a-button>
        </a-form-model-item>
      </a-form-model>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelCol: { span: 6 },
      wrapperCol: { span:18 },
      lab0: { span: 0 },
      wrap24: { span:24 },
      form: {
        account: '',
        password: ''
      },
      rules: {
        account: [
          {
            required: true,
            message: '请输入账号',
            trigger: 'change'
          }
        ],
        password: [
          {
            required: true,
            message: '请输入密码',
            trigger: 'change'
          }
        ]
      }
    }
  },
  methods:{
    login(){
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          this.$router.push({path:'/'})
        } else {
          return false;
        }
      });
      
    }
  }
}
</script>

<style scoped>
.login {
  width: 100vw;
  height: 100vh;
  /* background: dodgerblue; */
}
</style>